import React,{PureComponent} from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import {Card, Input} from 'antd';

import actions from '@/utils/globalStateActions'



interface homeProps {
  name?:string
}

interface homeState {
  name?:string
}

class Home extends PureComponent<homeProps,homeState> {

  constructor(props: Readonly<homeProps>) {
    super(props);
    this.state = {
      name:"此处显示数据"
    }
  }

  componentDidMount() {
    console.log("ssssssss")
    const  globalState = actions.getGlobalState(["name"]);
    console.log(globalState)
    this.setState({...globalState})
  }

  inputFun = (e:any) =>{
    actions.setGlobalState({name:e.target.value})
    this.setState({name:e.target.value});
  }

  render() {
    const {name} = this.state
    return (
      <PageHeaderWrapper>
        <Card>
          共享数据数据:{name}
          <Input value={name} onChange={this.inputFun}/>
        </Card>
      </PageHeaderWrapper>
    )
  }
}

export default Home;
